import 'package:flutter/material.dart';
import 'package:ost_flutter_module/common/adapt.dart';
import 'package:ost_flutter_module/common/color.dart';
import 'package:ost_flutter_module/common/styles.dart';
import 'package:ost_flutter_module/widget/custom_widget/text_button.dart';
import 'package:ost_flutter_module/widget/custom_widget/wrap_tag.dart';
import 'package:ost_flutter_module/widget/drop_down_widget/drop_down_widget.dart';

class DropDownBody extends StatelessWidget {
  final onTapF onTap;
  final DropDownBodyType type;
  const DropDownBody({Key key, this.onTap, this.type}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      child: type == DropDownBodyType.single ? _buildSingle() : _buildMutal(),
    );
  }

  Widget _buildSingle() => Padding(
        padding: EdgeInsets.all(Adapt.px(10)),
        child: Row(
          children: [
            WrapTag(
              titles: ['直播课', '面试课', 'OST课'],
              style: TextStyles.titleStyle,
              height: 36,
              padding: 28,
              borderRadius: 2,
              color: colorFAFAFA,
              spacing: 10,
              runSpacing: 10,
              onTap: onTap,
            ),
          ],
        ),
      );
  Widget _buildMutal() => Row(
        children: [
          Align(
            alignment: Alignment.topCenter,
            child: Container(
              color: colorFAFAFA,
              height: double.infinity,
              width: Adapt.px(100),
              child: ListView.builder(
                itemCount: 5,
                itemBuilder: (context, index) {
                  return Container(
                    color: Colors.white,
                    height: Adapt.px(44),
                    width: Adapt.px(100),
                    child: GTextButton(
                      title: ['广东省', '江西省', '江苏省', '上海市', '北京市'][index],
                      onPressed: () {},
                    ),
                  );
                },
              ),
            ),
          ),
          Expanded(
            child: Padding(
              padding: EdgeInsets.all(Adapt.px(10)),
              child: GridView.builder(
                  gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
                    crossAxisCount: 2,
                    childAspectRatio: 120 / 36,
                    mainAxisSpacing: Adapt.px(10),
                    crossAxisSpacing: Adapt.px(10),
                  ),
                  itemCount: 2,
                  itemBuilder: (c, index) {
                    return GTextButton(
                      title: ['宝安中心', '福田中心'][index],
                      normalBackgroundColor: colorFAFAFA,
                      padding: 0,
                      onPressed: () {},
                    );
                  }),
            ),
          ),
        ],
      );
}
